﻿<%@ Page Language="C#" MasterPageFile="~/admin/ADAdminLayout.master" AutoEventWireup="true"
    CodeFile="the_loai.aspx.cs" Inherits="admin_the_loai" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="block" id="block-tables">
        <div class="content">
            <h2 class="title">
                Thành Viên</h2>
            <div class="inner">
                <div class="group">
                    <label>
                        Từ khóa:</label>
                    <asp:TextBox ID="TextBox1" runat="server" class="text_field" size="60"></asp:TextBox>
                    &nbsp;
                    <label>
                        Tìm theo:
                    </label>
                    <select>
                        <option>Tên thành viên</option>
                        <option>Tên đăng nhập</option>
                        <option>Địa chỉ</option>
                    </select>
                    &nbsp;
                    <button class="button slim-button" type="submit">
                        <img src="./images/search.png" alt="Tìm kiếm">
                        Tìm kiếm</button>
                </div>
                <br />
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSourceTheLoai"
                    CssClass="table" oniteminserted="FormView1_ItemInserted">
                    <Columns>
                        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                            SortExpression="id" />
                        <asp:BoundField DataField="ten_the_loai" HeaderText="Tên thể loại" SortExpression="ten_the_loai" />
                        <asp:CommandField ShowEditButton="True" EditText="Sửa" UpdateText="Cập nhật" CancelText="Hủy bỏ"
                            ButtonType="Button" ControlStyle-Width="65px">
                            <ControlStyle Font-Size="Small" />
                        </asp:CommandField>
                    </Columns>
                </asp:GridView>
                <button class="button" type="button" onclick="$('#ctl00_ContentPlaceHolder1_FormView1').toggle('blind');">
                            Thêm thể loại mới
                        </button>
                <asp:SqlDataSource ID="SqlDataSourceTheLoai" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
                    InsertCommand="INSERT INTO [the_loai] ([ten_the_loai]) VALUES (@ten_the_loai)"
                    SelectCommand="SELECT * FROM [the_loai]" UpdateCommand="UPDATE [the_loai] SET [ten_the_loai] = @ten_the_loai WHERE [id] = @id">
                    <InsertParameters>
                        <asp:Parameter Name="ten_the_loai" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="ten_the_loai" Type="String" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </div>
        <br />
        <asp:FormView ID="FormView1" runat="server" Style="width: 100%; display: block;"
            CssClass="block form" DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert">
            <InsertItemTemplate>
                <div class="content">
                    <h2 class="title">
                        Thêm thể loại</h2>
                    <div class="inner">
                        <div class="group">
                            <label class="label">
                                Tên thể loại:</label>
                            <asp:TextBox size="70" class="text_field" ID="ten_the_loaiTextBox" runat="server"
                                Text='<%# Bind("ten_the_loai") %>' />
                        </div>
                        <div class="group navform wat-cf">
                            <asp:LinkButton CssClass="button" ID="InsertButton" runat="server" CausesValidation="True"
                                CommandName="Insert" Text="Thêm" />
                            <asp:LinkButton CssClass="text_button_padding link_button" ID="InsertCancelButton"
                                runat="server" CausesValidation="False" CommandName="Cancel" Text="Hủy" />
                        </div>
                    </div>
                </div>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Button ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="Thêm thể loại" />
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
            InsertCommand="INSERT INTO [the_loai] ([ten_the_loai]) VALUES (@ten_the_loai)"
            SelectCommand="SELECT * FROM [the_loai]" UpdateCommand="UPDATE [the_loai] SET [ten_the_loai] = @ten_the_loai WHERE [id] = @id">
            <InsertParameters>
                <asp:Parameter Name="ten_the_loai" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="id" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="ten_the_loai" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>
